
local additional_food=GLOBAL.aipGetModConfig("additional_food")
if additional_food~="open" then
return nil
end


local dev_mode=GLOBAL.aipGetModConfig("dev_mode")=="enabled"



local PROBABILITY=dev_mode and 1 or 0.15

local VEGGIES=GLOBAL.require('prefabs/aip_veggies_list')


function mergePickProduct(oriFunc,probability)
return function(inst)

if math.random() < probability then
local total_w=0
for veggiename,v in pairs(VEGGIES) do
total_w=total_w+(v.seed_weight or 1)
end

local rnd=math.random()*total_w
for veggiename,v in pairs(VEGGIES) do
rnd=rnd-(v.seed_weight or 1)
if rnd <=0 then
return "aip_veggie_"..veggiename
end
end
end


return oriFunc(inst)
end
end


AddPrefabPostInit("seeds",function(inst)
if not GLOBAL.TheWorld.ismastersim then
return
end


if inst.components.plantable then
local originPickProduct=inst.components.plantable.product
inst.components.plantable.product=mergePickProduct(originPickProduct,PROBABILITY)
end
end)


for name,data in pairs(VEGGIES) do
env.AddIngredientValues({"aip_veggie_"..name},data.tags or {},data.cancook or false,data.candry or false)
end
